import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommonFieldsVO, CommonFieldsForm, CommonFieldsQuery } from '@/api/system/commonFields/types';

/**
 * 查询常用字段列表
 * @param query
 * @returns {*}
 */

export const listCommonFields = (query?: CommonFieldsQuery): AxiosPromise<CommonFieldsVO[]> => {
  return request({
    url: '/system/commonFields/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询常用字段详细
 * @param id
 */
export const getCommonFields = (id: string | number): AxiosPromise<CommonFieldsVO> => {
  return request({
    url: '/system/commonFields/' + id,
    method: 'get'
  });
};

/**
 * 新增常用字段
 * @param data
 */
export const addCommonFields = (data: CommonFieldsForm) => {
  return request({
    url: '/system/commonFields',
    method: 'post',
    data: data
  });
};

/**
 * 修改常用字段
 * @param data
 */
export const updateCommonFields = (data: CommonFieldsForm) => {
  return request({
    url: '/system/commonFields',
    method: 'put',
    data: data
  });
};

/**
 * 删除常用字段
 * @param id
 */
export const delCommonFields = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/commonFields/' + id,
    method: 'delete'
  });
};
